import Taro, { Component } from '@tarojs/taro'
import { Swiper, SwiperItem, Text, View } from '@tarojs/components'
import './index.scss'

interface IProps {
  list: any
}

export default class Index extends Component<IProps, {}> {
  props: any
  state: any
  constructor () {
    super(...arguments)
    this.state = {
      current: 0
    }
  }

  onChangeSwiper(e) {
    this.setState({current: e.detail.current})
  }

  render() {
    const { current } = this.state
    const { list=[] } = this.props
    return (
      <View className='comment-carousel'>
        <Swiper
          autoplay
          // circular
          indicatorDots
          indicatorColor='#fff'
          indicatorActiveColor='#fff'
          className='img-list'
          // onChange={this.onChangeSwiper.bind(this)}
        >
          {list.map((url, k) => {
            return (<SwiperItem key={k}>
              <img src={url}/>
              {/*<Image src={url}/>*/}
            </SwiperItem>)
          })}
        </Swiper>
        {/*<View className='float-box'>{current + 1}<Text className='slash'/>{list.length}</View>*/}
      </View>
    )
  }
}
